package hephaestus.physics;

import java.util.HashMap;

public class Coordinate {

	private HashMap<String, Double> coordinates = new HashMap<String, Double>(); 
	
	public Coordinate()
	{
		setX(0);
		setY(0);
		setZ(0);
	}
	
	public Coordinate(double x)
	{
		setX(x);
		setY(0);
		setZ(0);
	}
	
	public Coordinate(double x, double y)
	{
		setX(x);
		setY(y);
		setZ(0);
	}
	
	public Coordinate(double x, double y, double z)
	{
		
		setX(x);
		setY(y);
		setZ(z);
		
	}
	
	public void setX(double x)
	{
		coordinates.put("x",x);
	}
	
	public void setY(double y)
	{
		coordinates.put("y",y);
	}
	
	public void setZ(double z)
	{
		System.out.println("SetZ called: "+z);
		coordinates.put("z",z);
	}
	
	public double getX()
	{
		return coordinates.get("x");
	}
	
	public double getY()
	{
		return coordinates.get("y");
	}
	
	public double getZ()
	{
		return coordinates.get("z");
	}
	
	public static Coordinate newCoordinate()
	{
		return new Coordinate();
	}
	
	public static Coordinate newCoordinate(double x, double y, double z)
	{
		return new Coordinate(x,y,z);
	}
	
	public double distanceTo(Coordinate c)
	{
		double diffX = c.getX()-getX();
		double diffY = c.getY()-getY();
		double diffZ = c.getZ()-getZ();	
		
		return Math.sqrt(Math.pow(diffX, 2)+Math.pow(diffY, 2)+Math.pow(diffZ, 2));
	}
}
